package com.spring.boot.dao.mapper;

import com.spring.boot.dao.model.*;
import java.util.List;
import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Options;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.ResultMap;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;
import org.apache.ibatis.annotations.Mapper;

@Mapper
public interface PublicMapper {

	/** appChannel 映射和相关方法 */
	@Insert("insert into app_channel (app_id, channel, sdk_name, channel_app_id, channel_app_key, channel_app_secret, channel_app_other, cdate, mdate) values (#{appChannel.appId}, #{appChannel.channel}, #{appChannel.sdkName}, #{appChannel.channelAppId}, #{appChannel.channelAppKey}, #{appChannel.channelAppSecret}, #{appChannel.channelAppOther}, #{appChannel.cdate}, #{appChannel.mdate})")
	public int insertAppChannel(@Param("appChannel") AppChannelDO appChannel);

	@Update("update app_channel set sdk_name = #{appChannel.sdkName}, channel_app_id = #{appChannel.channelAppId}, channel_app_key = #{appChannel.channelAppKey}, channel_app_secret = #{appChannel.channelAppSecret}, channel_app_other = #{appChannel.channelAppOther}, cdate = #{appChannel.cdate}, mdate = #{appChannel.mdate} where app_id = #{appChannel.appId} and channel = #{appChannel.channel}")
	public int updateAppChannelByPrimaryKey(@Param("appChannel") AppChannelDO appChannel);

	@Update("replace into app_channel(app_id, channel, sdk_name, channel_app_id, channel_app_key, channel_app_secret, channel_app_other, cdate, mdate) values (#{appChannel.appId}, #{appChannel.channel}, #{appChannel.sdkName}, #{appChannel.channelAppId}, #{appChannel.channelAppKey}, #{appChannel.channelAppSecret}, #{appChannel.channelAppOther}, #{appChannel.cdate}, #{appChannel.mdate})")
	public int setAppChannel(@Param("appChannel") AppChannelDO appChannel);

	@Select("select * from app_channel where app_id = #{#s} and channel = #{#s}")
	@ResultMap("com.spring.boot.dao.mapper.PublicMapper.AppChannelMap")
	public AppChannelDO selectAppChannelByPrimaryKey(@Param("appId") Integer appId, @Param("channel") String channel);

	@Delete("delete from app_channel where app_id = #{appId} and channel = #{channel}")
	public int deleteAppChannelByPrimaryKey(@Param("appId") Integer appId, @Param("channel") String channel);

	/** deviceTokenIos 映射和相关方法 */
	@Insert("insert into device_token_ios (user_id, device_token, is_active_flag, cdate, mdate) values (#{deviceTokenIos.userId}, #{deviceTokenIos.deviceToken}, #{deviceTokenIos.isActiveFlag}, #{deviceTokenIos.cdate}, #{deviceTokenIos.mdate})")
	public int insertDeviceTokenIos(@Param("deviceTokenIos") DeviceTokenIosDO deviceTokenIos);

	@Update("update device_token_ios set device_token = #{deviceTokenIos.deviceToken}, is_active_flag = #{deviceTokenIos.isActiveFlag}, cdate = #{deviceTokenIos.cdate}, mdate = #{deviceTokenIos.mdate} where user_id = #{deviceTokenIos.userId}")
	public int updateDeviceTokenIosByPrimaryKey(@Param("deviceTokenIos") DeviceTokenIosDO deviceTokenIos);

	@Update("replace into device_token_ios(user_id, device_token, is_active_flag, cdate, mdate) values (#{deviceTokenIos.userId}, #{deviceTokenIos.deviceToken}, #{deviceTokenIos.isActiveFlag}, #{deviceTokenIos.cdate}, #{deviceTokenIos.mdate})")
	public int setDeviceTokenIos(@Param("deviceTokenIos") DeviceTokenIosDO deviceTokenIos);

	@Select("select * from device_token_ios where user_id = #{userId}")
	@ResultMap("com.spring.boot.dao.mapper.PublicMapper.DeviceTokenIosMap")
	public DeviceTokenIosDO getDeviceTokenIos (@Param("userId") Long userId );

	@Delete("delete from device_token_ios where user_id = #{userId}")
	public int deleteDeviceTokenIosByPrimaryKey(@Param("userId") Long userId);

	/** deviceTokenAndroid 映射和相关方法 */
	@Insert("insert into device_token_android (user_id, device_token, is_active_flag, cdate, mdate) values (#{deviceTokenAndroid.userId}, #{deviceTokenAndroid.deviceToken}, #{deviceTokenAndroid.isActiveFlag}, #{deviceTokenAndroid.cdate}, #{deviceTokenAndroid.mdate})")
	public int insertDeviceTokenAndroid(@Param("deviceTokenAndroid") DeviceTokenAndroidDO deviceTokenAndroid);

	@Update("update device_token_android set device_token = #{deviceTokenAndroid.deviceToken}, is_active_flag = #{deviceTokenAndroid.isActiveFlag}, cdate = #{deviceTokenAndroid.cdate}, mdate = #{deviceTokenAndroid.mdate} where user_id = #{deviceTokenAndroid.userId}")
	public int updateDeviceTokenAndroidByPrimaryKey(@Param("deviceTokenAndroid") DeviceTokenAndroidDO deviceTokenAndroid);

	@Update("replace into device_token_android(user_id, device_token, is_active_flag, cdate, mdate) values (#{deviceTokenAndroid.userId}, #{deviceTokenAndroid.deviceToken}, #{deviceTokenAndroid.isActiveFlag}, #{deviceTokenAndroid.cdate}, #{deviceTokenAndroid.mdate})")
	public int setDeviceTokenAndroid(@Param("deviceTokenAndroid") DeviceTokenAndroidDO deviceTokenAndroid);

	@Select("select * from device_token_android where user_id = #{userId}")
	@ResultMap("com.spring.boot.dao.mapper.PublicMapper.DeviceTokenAndroidMap")
	public DeviceTokenAndroidDO getDeviceTokenAndroid (@Param("userId") Long userId );

	@Delete("delete from device_token_android where user_id = #{userId}")
	public int deleteDeviceTokenAndroidByPrimaryKey(@Param("userId") Long userId);

	/** streamLog 映射和相关方法 */
	@Insert("insert into stream_log (user_id, live_user_id, user_type, connect_time, buffer_time, network_env, cdn, ip, cdate) values (#{streamLog.userId}, #{streamLog.liveUserId}, #{streamLog.userType}, #{streamLog.connectTime}, #{streamLog.bufferTime}, #{streamLog.networkEnv}, #{streamLog.cdn}, #{streamLog.ip}, #{streamLog.cdate})")
	@Options(useGeneratedKeys = true, keyProperty = "streamLog.id")
	public int insertStreamLog(@Param("streamLog") StreamLogDO streamLog);

	@Update("update stream_log set user_id = #{streamLog.userId}, live_user_id = #{streamLog.liveUserId}, user_type = #{streamLog.userType}, connect_time = #{streamLog.connectTime}, buffer_time = #{streamLog.bufferTime}, network_env = #{streamLog.networkEnv}, cdn = #{streamLog.cdn}, ip = #{streamLog.ip}, cdate = #{streamLog.cdate} where id = #{streamLog.id}")
	public int updateStreamLogByPrimaryKey(@Param("streamLog") StreamLogDO streamLog);

	@Select("select * from stream_log where user_id = #{userId}")
	@ResultMap("com.spring.boot.dao.mapper.PublicMapper.StreamLogMap")
	public List<StreamLogDO> getStreamLogs (@Param("userId") Long userId );

	@Select("select * from stream_log where id = #{id}")
	@ResultMap("com.spring.boot.dao.mapper.PublicMapper.StreamLogMap")
	public StreamLogDO selectStreamLogByPrimaryKey(@Param("id") Long id);

	@Delete("delete from stream_log where id = #{id}")
	public int deleteStreamLogByPrimaryKey(@Param("id") Long id);

	/** reportUser 映射和相关方法 */
	@Insert("insert into report_user (from_user_id, to_user_id, report_type, process_status, cdate, mdate) values (#{reportUser.fromUserId}, #{reportUser.toUserId}, #{reportUser.reportType}, #{reportUser.processStatus}, #{reportUser.cdate}, #{reportUser.mdate})")
	@Options(useGeneratedKeys = true, keyProperty = "reportUser.id")
	public int insertReportUser(@Param("reportUser") ReportUserDO reportUser);

	@Update("update report_user set from_user_id = #{reportUser.fromUserId}, to_user_id = #{reportUser.toUserId}, report_type = #{reportUser.reportType}, process_status = #{reportUser.processStatus}, cdate = #{reportUser.cdate}, mdate = #{reportUser.mdate} where id = #{reportUser.id}")
	public int updateReportUserByPrimaryKey(@Param("reportUser") ReportUserDO reportUser);

	@Select("select * from report_user where id = #{id}")
	@ResultMap("com.spring.boot.dao.mapper.PublicMapper.ReportUserMap")
	public ReportUserDO selectReportUserByPrimaryKey(@Param("id") Long id);

	@Delete("delete from report_user where id = #{id}")
	public int deleteReportUserByPrimaryKey(@Param("id") Long id);

	/** tCash 映射和相关方法 */
	@Insert("insert into t_cash (provider_id, tx_name, cost, description, credit, credit_unit, is_active_flag, cdate) values (#{tCash.providerId}, #{tCash.txName}, #{tCash.cost}, #{tCash.description}, #{tCash.credit}, #{tCash.creditUnit}, #{tCash.isActiveFlag}, #{tCash.cdate})")
	@Options(useGeneratedKeys = true, keyProperty = "tCash.tcId")
	public int insertTCash(@Param("tCash") TCashDO tCash);

	@Update("update t_cash set provider_id = #{tCash.providerId}, tx_name = #{tCash.txName}, cost = #{tCash.cost}, description = #{tCash.description}, credit = #{tCash.credit}, credit_unit = #{tCash.creditUnit}, is_active_flag = #{tCash.isActiveFlag}, cdate = #{tCash.cdate} where tc_id = #{tCash.tcId}")
	public int updateTCashByPrimaryKey(@Param("tCash") TCashDO tCash);

	@Select("select * from t_cash where tc_id = #{tcId}")
	@ResultMap("com.spring.boot.dao.mapper.PublicMapper.TCashMap")
	public TCashDO selectTCashByPrimaryKey(@Param("tcId") Integer tcId);
	

	@Delete("delete from t_cash where tc_id = #{tcId}")
	public int deleteTCashByPrimaryKey(@Param("tcId") Integer tcId);

	/** userCashLog 映射和相关方法 */
	@Insert("insert into user_cash_log (id, user_id, plat_type, recipe, status, cdate) values (#{userCashLog.id}, #{userCashLog.userId}, #{userCashLog.platType}, #{userCashLog.recipe}, #{userCashLog.status}, #{userCashLog.cdate})")
	public int insertUserCashLog(@Param("userCashLog") UserCashLogDO userCashLog);

	@Update("update user_cash_log set user_id = #{userCashLog.userId}, plat_type = #{userCashLog.platType}, recipe = #{userCashLog.recipe}, status = #{userCashLog.status}, cdate = #{userCashLog.cdate} where id = #{userCashLog.id}")
	public int updateUserCashLogByPrimaryKey(@Param("userCashLog") UserCashLogDO userCashLog);

	@Update("replace into user_cash_log(id, user_id, plat_type, recipe, status, cdate) values (#{userCashLog.id}, #{userCashLog.userId}, #{userCashLog.platType}, #{userCashLog.recipe}, #{userCashLog.status}, #{userCashLog.cdate})")
	public int setUserCashLog(@Param("userCashLog") UserCashLogDO userCashLog);

	@Select("select * from user_cash_log where user_id = #{userId}")
	@ResultMap("com.spring.boot.dao.mapper.PublicMapper.UserCashLogMap")
	public List<UserCashLogDO> getUserCashLogs (@Param("userId") Long userId );

	@Select("select * from user_cash_log where id = #{id}")
	@ResultMap("com.spring.boot.dao.mapper.PublicMapper.UserCashLogMap")
	public UserCashLogDO selectUserCashLogByPrimaryKey(@Param("id") String id);

	@Delete("delete from user_cash_log where id = #{id}")
	public int deleteUserCashLogByPrimaryKey(@Param("id") String id);

	/** userCash 映射和相关方法 */
	@Insert("insert into user_cash (out_trade_no, trade_no, user_id, goods_id, goods_count, price, total_fee, seller_id, seller_email, buyer_id, buyer_email, pay_status, ext, cdate, mdate) values (#{userCash.outTradeNo}, #{userCash.tradeNo}, #{userCash.userId}, #{userCash.goodsId}, #{userCash.goodsCount}, #{userCash.price}, #{userCash.totalFee}, #{userCash.sellerId}, #{userCash.sellerEmail}, #{userCash.buyerId}, #{userCash.buyerEmail}, #{userCash.payStatus}, #{userCash.ext}, #{userCash.cdate}, #{userCash.mdate})")
	public int insertUserCash(@Param("userCash") UserCashDO userCash);

	@Select("select * from user_cash where user_id = #{userId}")
	@ResultMap("com.spring.boot.dao.mapper.PublicMapper.UserCashMap")
	public List<UserCashDO> getUserCashs (@Param("userId") Long userId );

	/** userWithdraw 映射和相关方法 */
	@Insert("insert into user_withdraw (user_id, mch_billno, total_amount, status, result_msg, cdate) values (#{userWithdraw.userId}, #{userWithdraw.mchBillno}, #{userWithdraw.totalAmount}, #{userWithdraw.status}, #{userWithdraw.resultMsg}, #{userWithdraw.cdate})")
	@Options(useGeneratedKeys = true, keyProperty = "userWithdraw.id")
	public int insertUserWithdraw(@Param("userWithdraw") UserWithdrawDO userWithdraw);

	@Update("update user_withdraw set user_id = #{userWithdraw.userId}, mch_billno = #{userWithdraw.mchBillno}, total_amount = #{userWithdraw.totalAmount}, status = #{userWithdraw.status}, result_msg = #{userWithdraw.resultMsg}, cdate = #{userWithdraw.cdate} where id = #{userWithdraw.id}")
	public int updateUserWithdrawByPrimaryKey(@Param("userWithdraw") UserWithdrawDO userWithdraw);

	@Select("select * from user_withdraw where user_id = #{userId}")
	@ResultMap("com.spring.boot.dao.mapper.PublicMapper.UserWithdrawMap")
	public List<UserWithdrawDO> getUserWithdraws (@Param("userId") Long userId );

	@Select("select * from user_withdraw where id = #{id}")
	@ResultMap("com.spring.boot.dao.mapper.PublicMapper.UserWithdrawMap")
	public UserWithdrawDO selectUserWithdrawByPrimaryKey(@Param("id") Long id);

	@Delete("delete from user_withdraw where id = #{id}")
	public int deleteUserWithdrawByPrimaryKey(@Param("id") Long id);

	/** userInfo 映射和相关方法 */
	@Insert("insert into user_info (user_id, money, money_used, coin, coin_used, cdate, mdate) values (#{userInfo.userId}, #{userInfo.money}, #{userInfo.moneyUsed}, #{userInfo.coin}, #{userInfo.coinUsed}, #{userInfo.cdate}, #{userInfo.mdate})")
	public int insertUserInfo(@Param("userInfo") UserInfoDO userInfo);

	@Update("update user_info set money = #{userInfo.money}, money_used = #{userInfo.moneyUsed}, coin = #{userInfo.coin}, coin_used = #{userInfo.coinUsed}, cdate = #{userInfo.cdate}, mdate = #{userInfo.mdate} where user_id = #{userInfo.userId}")
	public int updateUserInfoByPrimaryKey(@Param("userInfo") UserInfoDO userInfo);

	@Update("replace into user_info(user_id, money, money_used, coin, coin_used, cdate, mdate) values (#{userInfo.userId}, #{userInfo.money}, #{userInfo.moneyUsed}, #{userInfo.coin}, #{userInfo.coinUsed}, #{userInfo.cdate}, #{userInfo.mdate})")
	public int setUserInfo(@Param("userInfo") UserInfoDO userInfo);

	@Select("select * from user_info where user_id = #{userId}")
	@ResultMap("com.spring.boot.dao.mapper.PublicMapper.UserInfoMap")
	public UserInfoDO getUserInfo (@Param("userId") Long userId );
	
	@Select("select * from user_info")
	@ResultMap("com.spring.boot.dao.mapper.PublicMapper.UserInfoMap")
	public List<UserInfoDO> getAllUserInfo ();

	@Delete("delete from user_info where user_id = #{userId}")
	public int deleteUserInfoByPrimaryKey(@Param("userId") Long userId);

	/** userMoneyExchange 映射和相关方法 */
	@Insert("insert into user_money_exchange (user_id, get_val, val_after_tx, action_id, remark, cdate, mdate) values (#{userMoneyExchange.userId}, #{userMoneyExchange.getVal}, #{userMoneyExchange.valAfterTx}, #{userMoneyExchange.actionId}, #{userMoneyExchange.remark}, #{userMoneyExchange.cdate}, #{userMoneyExchange.mdate})")
	@Options(useGeneratedKeys = true, keyProperty = "userMoneyExchange.id")
	public int insertUserMoneyExchange(@Param("userMoneyExchange") UserMoneyExchangeDO userMoneyExchange);

	@Update("update user_money_exchange set user_id = #{userMoneyExchange.userId}, get_val = #{userMoneyExchange.getVal}, val_after_tx = #{userMoneyExchange.valAfterTx}, action_id = #{userMoneyExchange.actionId}, remark = #{userMoneyExchange.remark}, cdate = #{userMoneyExchange.cdate}, mdate = #{userMoneyExchange.mdate} where id = #{userMoneyExchange.id}")
	public int updateUserMoneyExchangeByPrimaryKey(@Param("userMoneyExchange") UserMoneyExchangeDO userMoneyExchange);

	@Select("select * from user_money_exchange where user_id = #{userId}")
	@ResultMap("com.spring.boot.dao.mapper.PublicMapper.UserMoneyExchangeMap")
	public List<UserMoneyExchangeDO> getUserMoneyExchanges (@Param("userId") Long userId );

	@Select("select * from user_money_exchange where id = #{id}")
	@ResultMap("com.spring.boot.dao.mapper.PublicMapper.UserMoneyExchangeMap")
	public UserMoneyExchangeDO selectUserMoneyExchangeByPrimaryKey(@Param("id") Long id);

	@Delete("delete from user_money_exchange where id = #{id}")
	public int deleteUserMoneyExchangeByPrimaryKey(@Param("id") Long id);

	/** userCoinExchange 映射和相关方法 */
	@Insert("insert into user_coin_exchange (user_id, get_val, val_after_tx, action_id, remark, cdate, mdate) values (#{userCoinExchange.userId}, #{userCoinExchange.getVal}, #{userCoinExchange.valAfterTx}, #{userCoinExchange.actionId}, #{userCoinExchange.remark}, #{userCoinExchange.cdate}, #{userCoinExchange.mdate})")
	@Options(useGeneratedKeys = true, keyProperty = "userCoinExchange.id")
	public int insertUserCoinExchange(@Param("userCoinExchange") UserCoinExchangeDO userCoinExchange);

	@Update("update user_coin_exchange set user_id = #{userCoinExchange.userId}, get_val = #{userCoinExchange.getVal}, val_after_tx = #{userCoinExchange.valAfterTx}, action_id = #{userCoinExchange.actionId}, remark = #{userCoinExchange.remark}, cdate = #{userCoinExchange.cdate}, mdate = #{userCoinExchange.mdate} where id = #{userCoinExchange.id}")
	public int updateUserCoinExchangeByPrimaryKey(@Param("userCoinExchange") UserCoinExchangeDO userCoinExchange);

	@Select("select * from user_coin_exchange where user_id = #{userId}")
	@ResultMap("com.spring.boot.dao.mapper.PublicMapper.UserCoinExchangeMap")
	public List<UserCoinExchangeDO> getUserCoinExchanges (@Param("userId") Long userId );

	@Select("select * from user_coin_exchange where id = #{id}")
	@ResultMap("com.spring.boot.dao.mapper.PublicMapper.UserCoinExchangeMap")
	public UserCoinExchangeDO selectUserCoinExchangeByPrimaryKey(@Param("id") Long id);

	@Delete("delete from user_coin_exchange where id = #{id}")
	public int deleteUserCoinExchangeByPrimaryKey(@Param("id") Long id);

	/** tDoren 映射和相关方法 */
	@Insert("insert into t_doren (sort, user_id, content, cdate) values (#{tDoren.sort}, #{tDoren.userId}, #{tDoren.content}, #{tDoren.cdate})")
	@Options(useGeneratedKeys = true, keyProperty = "tDoren.tdId")
	public int insertTDoren(@Param("tDoren") TDorenDO tDoren);

	@Update("update t_doren set sort = #{tDoren.sort}, user_id = #{tDoren.userId}, content = #{tDoren.content}, cdate = #{tDoren.cdate} where td_id = #{tDoren.tdId}")
	public int updateTDorenByPrimaryKey(@Param("tDoren") TDorenDO tDoren);

	@Select("select * from t_doren where user_id = #{userId}")
	@ResultMap("com.spring.boot.dao.mapper.PublicMapper.TDorenMap")
	public List<TDorenDO> getTDorens (@Param("userId") Long userId );

	@Select("select * from t_doren where td_id = #{tdId}")
	@ResultMap("com.spring.boot.dao.mapper.PublicMapper.TDorenMap")
	public TDorenDO selectTDorenByPrimaryKey(@Param("tdId") Integer tdId);

	@Delete("delete from t_doren where td_id = #{tdId}")
	public int deleteTDorenByPrimaryKey(@Param("tdId") Integer tdId);

	/** tBannerAds 映射和相关方法 */
	@Insert("insert into t_banner_ads (banner_pic, content, is_active_flag, sort, ads_type_id, cdate, mdate) values (#{tBannerAds.bannerPic}, #{tBannerAds.content}, #{tBannerAds.isActiveFlag}, #{tBannerAds.sort}, #{tBannerAds.adsTypeId}, #{tBannerAds.cdate}, #{tBannerAds.mdate})")
	@Options(useGeneratedKeys = true, keyProperty = "tBannerAds.tbId")
	public int insertTBannerAds(@Param("tBannerAds") TBannerAdsDO tBannerAds);

	@Update("update t_banner_ads set banner_pic = #{tBannerAds.bannerPic}, content = #{tBannerAds.content}, is_active_flag = #{tBannerAds.isActiveFlag}, sort = #{tBannerAds.sort}, ads_type_id = #{tBannerAds.adsTypeId}, cdate = #{tBannerAds.cdate}, mdate = #{tBannerAds.mdate} where tb_id = #{tBannerAds.tbId}")
	public int updateTBannerAdsByPrimaryKey(@Param("tBannerAds") TBannerAdsDO tBannerAds);

	@Select("select * from t_banner_ads where tb_id = #{tbId}")
	@ResultMap("com.spring.boot.dao.mapper.PublicMapper.TBannerAdsMap")
	public TBannerAdsDO selectTBannerAdsByPrimaryKey(@Param("tbId") Integer tbId);

	@Delete("delete from t_banner_ads where tb_id = #{tbId}")
	public int deleteTBannerAdsByPrimaryKey(@Param("tbId") Integer tbId);

}
